home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / TestTools / Sources / TestTimeStamp.cp < prev    next >
Encoding:
Text File  |  1996-11-19  |  3.0 KB  |  119 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TestTimeStamp.cp
  3.  
  4.     Contains:    Tester for the TTimeStamp class
  5.  
  6.     Copyright:    © 1991-1994 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #ifndef __TESTTIMESTAMP__
  11. #include "TestTimeStamp.h"
  12. #endif
  13.  
  14. /*******************************************************************************
  15. ** Constructor/Destructor
  16. ********************************************************************************/
  17.  
  18. Constructor(TimeStamp)
  19. Destructor(TimeStamp)
  20.  
  21. /**********************************************************************
  22. ** PUBLIC InitTest
  23. ***********************************************************************/
  24.  
  25. void TTestTimeStamp::InitTest(BooleanParm, BooleanParm, int, char**)
  26. {    
  27.     TStandardPool* pool = GetPool();
  28.  
  29.     if (pool == NULL)
  30.     {
  31.         Printf("### ERROR: There is no global pool\n");
  32.         return;
  33.     }
  34.         
  35.     if ((fTest = new (pool) TStopwatch) == NULL)
  36.         Printf("### ERROR: Couldn't create a new TStopWatch\n");
  37. }
  38.  
  39. /**********************************************************************
  40. ** PUBLIC RunTestIteration
  41. ***********************************************************************/
  42.  
  43. void TTestTimeStamp::RunTestIteration(BooleanParm, BooleanParm)
  44. {
  45.     unsigned long    time;
  46.     TStopwatch*        watch = (TStopwatch*)fTest;
  47.     
  48.     unsigned long tick = *(unsigned long *)0x16A;
  49.     while (tick == *(unsigned long *)0x16a)
  50.         ;
  51.     watch->Reset();
  52.     tick = *(unsigned long *)0x16A;
  53.     while (tick == *(unsigned long *)0x16a)
  54.         ;
  55.     time = watch->ElapsedMicroseconds();
  56.     Printf("INFO: 1 Tick = %u Microseconds\n", time);
  57.  
  58.     tick = *(unsigned long *)0x16A;
  59.     while (tick == *(unsigned long *)0x16a)
  60.         ;
  61.     watch->Reset();
  62.     tick = *(unsigned long *)0x16A;
  63.     while (tick == *(unsigned long *)0x16a)
  64.         ;
  65.     time = watch->ElapsedMilliseconds();
  66.     Printf("INFO: 1 Tick = %u Milliseconds\n", time);
  67.  
  68.     tick = *(unsigned long *)0x16A;
  69.     while (tick == *(unsigned long *)0x16a)
  70.         ;
  71.     watch->Reset();
  72.     tick = *(unsigned long *)0x16A;
  73.     while (tick == *(unsigned long *)0x16a)
  74.         ;
  75.     time = watch->ElapsedSeconds();
  76.     Printf("INFO: 1 Tick = %u Seconds\n", time);
  77.  
  78.  
  79.     tick = *(unsigned long *)0x16A;
  80.     while (tick == *(unsigned long *)0x16a)
  81.         ;
  82.     watch->Reset();
  83.     tick = *(unsigned long *)0x16A;
  84.     while (*(unsigned long *)0x16a - tick < 60)
  85.         ;
  86.     time = watch->ElapsedMicroseconds();
  87.     Printf("INFO: 1 Second = %u Microseconds\n", time);
  88.  
  89.     tick = *(unsigned long *)0x16A;
  90.     while (tick == *(unsigned long *)0x16a)
  91.         ;
  92.     watch->Reset();
  93.     tick = *(unsigned long *)0x16A;
  94.     while (*(unsigned long *)0x16a - tick < 60)
  95.         ;
  96.     time = watch->ElapsedMilliseconds();
  97.     Printf("INFO: 1 Second = %u Milliseconds\n", time);
  98.  
  99.     tick = *(unsigned long *)0x16A;
  100.     while (tick == *(unsigned long *)0x16a)
  101.         ;
  102.     watch->Reset();
  103.     tick = *(unsigned long *)0x16A;
  104.     while (*(unsigned long *)0x16a - tick < 60)
  105.         ;
  106.     time = watch->ElapsedSeconds();
  107.     Printf("INFO: 1 Second = %u Seconds\n", time);
  108. }
  109.  
  110. /**********************************************************************
  111. ** PUBLIC EndTest
  112. ***********************************************************************/
  113.  
  114. void TTestTimeStamp::EndTest(BooleanParm, BooleanParm)
  115. {
  116.     delete fTest;
  117.     fTest = NULL;
  118. }
  119.